/**************************************************
|	File:		Enemy.h
|	Author:		Benjamin Budian
|	Course:		SGD
|	Purpose:	CEnemy is responsible for handling how enemy behavior
**************************************************/

#pragma once
#include "entity.h"
#include "../SGD Wrappers/IListener.h"

#include "CreateProjectileMessage.h"

class CCellAnimation;

enum CharacterTypes { SKELETON, ORC, HUMAN, NUMBER_CHARACTER_TYPES };

class CEnemy :
	public CEntity, public IListener
{
	enum MovementDirection		{ MOVE_UP = 104, MOVE_DOWN = 130, MOVE_LEFT = 117, MOVE_RIGHT = 143 };

public:
	CEnemy(void);
	virtual ~CEnemy(void);

	void Initialize(int nEnemyType);

	virtual void Update( float fElapsedTime ) override;
	virtual void Render() override;
	virtual void HandleCollision( const IEntity* pOther )	override;
	virtual void HandleEvent( CEvent* pEvent )	override;

	//Accessors
	float	GetDamage	( void ) const	{	return	m_fDamage;	}
	short	GetHealth	( void ) const  {	return	m_sHealth;	}
	short	GetMana		( void ) const	{	return	m_sMana;	}

	//Mutators
	void	SetDamage	( float fDamage )	{	m_fDamage	= fDamage;	}
	void	SetHealth	( short sHealth	)	{	m_sHealth	= sHealth;	}
	void	SetMana		( short sMana	)	{	m_sMana		= sMana;	}
	void	SetTarget	( CEntity* pTarget);
	void	SetArmor	( int nArmor )	{	m_nArmor = nArmor; }
	void	SetFireTimer( float fFireTimer) {	m_fFireTimerMax = fFireTimer; }

	//Other Methods
	void	TakeDamage	( short sDamage )	{	m_sHealth -= sDamage;	}
	void	Fire( Projectile_Directions eDirection);
	void	SetDebugMode( bool bDebug )		{ m_bDebug = bDebug; }

private:

	enum AttackDirection		{ ATTACK_UP, ATTACK_LEFT, ATTACK_DOWN, ATTACK_RIGHT };
	enum Weapon					{ SWORD = 12, BOW = 16 };
	enum NumberOfWeaponCells	{ SWORD_CELLS = 6, BOW_CELLS = 13 };

	void HandleAI();
	void GetNewWaypoint();
	void StayInWorld();
	void ChangeDirection();
	void ChangeAttackDirection	( AttackDirection eAttackDirection	);

	CCellAnimation* EnemyAnimation;
	CCellAnimation* WeaponAnimation;

	MovementDirection	m_eMovementDirection;
	MovementDirection	m_ePreviousMovementDirection;
	AttackDirection		m_eAttackDirection;
	
	CEntity* m_pTarget;

	CharacterTypes type;

	unsigned char m_cArmor;

	short m_sHealth;
	short m_sMana;
	float m_fDamage;
	int m_nHealthBarImgID;
	int m_nArmor;

	float m_fSpeed;
	
	int m_nImageID;

	float	m_fWaypointX,	m_fWaypointY;
	float	m_fTempWaypointX, m_fTempWaypointY;
	bool	m_bTravelingX,	m_bTravelingY;
	bool	m_bTraveledX,	m_bTraveledY;
	bool	m_bTraveling;
	bool	m_bDebug;

	float	m_fFireTimer;
	float	m_fFireTimerMax;

	//Debug purposes only
	bool	m_bCalculate;

	bool	m_bTrackingTarget;

};

